// vconsole注入

const vconsole = require('../../config/vconsole.config.js')

// vconsole资源
const resource = vconsole.resource
// 是否移动端
const isMobile =
  'navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)'
module.exports = `
// config/vconsole.config.js 配置
if ( ${isMobile} ) {
    var script = document.createElement('script')
    var firstScript = document.getElementsByTagName('script')[0]
    document.getElementsByTagName('head')[0].insertBefore(script, firstScript)
    script.src = "${resource}"
    script.onload = function() {
        new VConsole()
    }
}
`
